package com.yaozheng.vocationaltraining.view;

import net.sf.json.JSONObject;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.utils.TypeUtils;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 题号
 * 
 * @author Administrator
 * 
 */
@EViewGroup(R.layout.item_question_number)
public class QuestionNumberItemView extends LinearLayout {
	@ViewById
	TextView itemQuestionNemberText;
	int position;


	public QuestionNumberItemView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public QuestionNumberItemView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public int getPosition() {
		return position;
	}

	/**
	 * 加载数据
	 * 
	 * @param position
	 * @param isSelectCurr
	 *            true 选中当前
	 */
	public void loadData(int position, JSONObject questionObject,
			boolean isSelectCurr) {
		this.position = position;
		itemQuestionNemberText.setText(String.valueOf(position + 1));
		int questionStatus = TypeUtils.getJsonInteger(questionObject,
				"questionStatus", 0);
		if (isSelectCurr) {
			// 当前
			itemQuestionNemberText.setSelected(true);
			itemQuestionNemberText.setEnabled(false);
		} else if (questionStatus == 1) {
			// 已做
			itemQuestionNemberText.setSelected(false);
			itemQuestionNemberText.setEnabled(true);
		} else {

			// 未做
			itemQuestionNemberText.setSelected(true);
			itemQuestionNemberText.setEnabled(true);
		}
	}
}
